<template>
    <div class="tips-box">
        <div>tips:总价 {{ goodsTotals.totalPrice }}</div>
        <div>成交数量合计：{{ goodsTotals.tranNumber }}</div>
        <div>法定第一数量合计：{{ goodsTotals.legalFirst }}</div>
        <div>法定第二数量合计：{{ goodsTotals.legalSecond }}</div>
    </div>
</template>
<script>
import { evenRound } from '@/libs/tools'
export default {
    props: {
        goodsList: {
            type: Array,
            default: () => []
        }
    },
    computed: {
        goodsTotals () {
            let totalPrice = 0
            let tranNumber = 0
            let legalFirst = 0
            let legalSecond = 0
            this.goodsList.forEach(item => {
                const { declTotal, gqty, firstQty, secondQty } = item
                totalPrice += Number(declTotal)
                tranNumber += Number(gqty)
                legalFirst += Number(firstQty)
                legalSecond += Number(secondQty)
            })
            return {
                totalPrice: evenRound(totalPrice, 2),
                tranNumber: evenRound(tranNumber, 5),
                legalFirst: evenRound(legalFirst, 5),
                legalSecond: evenRound(legalSecond, 5)
            }
        }
    }
}
</script>
